package
{
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;
	
	import jiglib.physics.RigidBody;
	import jiglib.plugin.away3d.Away3DPhysics;

	public class DefaultInputHandler implements IInputHandler
	{
		private var m_physics:Away3DPhysics;
		public function DefaultInputHandler(physics:Away3DPhysics)
		{
			m_physics = physics; 
			
		}
		
		public function onMouseMove(me:MouseEvent):void{
			
		}
		
		public function onMouseDown(me:MouseEvent):void{
			
		}
		
		public function onMouseUp(me:MouseEvent):void{
			var x:int = Math.round(Math.random()*100)*10 - 500;
			var z:int = Math.round(Math.random()*100)*10 - 500;
			var y:int = 0;
			
			this.createBall(new Vector3D(x, y, z));
		}
		
		public function onMouseWheel(me:MouseEvent):void{
			
		}			
		
		public function onKeyDown(ke:KeyboardEvent):void{
			
		}
		
		public function onKeyUp(ke:KeyboardEvent):void{
			
		}	
		
		private function createBall(pos:Vector3D):void{
			var ball:RigidBody = m_physics.createSphere({radius: 10});
			ball.y = 200;
			ball.x = pos.x;
			ball.z = pos.z;
			ball.addBodyForce(new Vector3D(Math.round((Math.random()-.5)*100),0,0),new Vector3D(Math.round((Math.random()-.5)*100),0,0));
		}		
	}
}